package org.micro.alibaba.consumer.controller;

import org.micro.alibaba.common.domain.User;
import org.micro.alibaba.consumer.feign.OrderFeignClient;
import org.micro.alibaba.consumer.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author keven
 * @date 2025-06-25 7:48 下午
 * @Description
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;
    @Autowired
    private OrderFeignClient orderFeignClient;

    @GetMapping("/getUserById")
    public User test(Long userId) {
        return userService.getById(userId);
    }


    @PostMapping("/buyItem")
    public void buyItem(Integer userId,Integer itemId,Integer num) {
        orderFeignClient.createOrder(userId,itemId,num);
    }

}
